<template>
	<view class="rank-continer">
		<view v-for="(item,index) in list" :key="index" class="list">
			<text class="rank-text">{{item.rank}}</text>
			<text>{{item.username}}</text>
			<text class="count">{{item.coinCount}}</text>
		</view>
	</view>
</template>

<script>
	import {
		rankList
	} from '@/api/constant.js'


	export default {
		data() {
			return {
				list: [],
				index:1,
				totalCount:''
			}
		},
		onPullDownRefresh(){
			this.list=[]
			this.index=1
			this.fetLists()
			uni.stopPullDownRefresh()
			
		}
,		onLoad() {
			this.fetLists()

		},
		onReachBottom() {
			
			this.index++
			this.fetLists()
		},
		methods: {
			async fetLists() {
				//1/json
				let res = await this.$httpGet(`${rankList}/${this.index}/json`)
				this.totalCount=res.data.total
				this.list = this.list.concat(res.data.datas)
				
			}
		}
	}
</script>

<style lang="scss">
	.rank-continer {
		font-size: 36rpx;
		padding: 32rpx;

		.list {
			display: flex;
			padding: 12rpx;
			border-bottom: 1px solid gray;

			.count {
				margin-left: auto;
				color: green;
			}
		}

		.rank-text {
			display: flex;
			width: 100rpx;

		}

		>view>text {
			margin-right: 16rpx;
		}
	}
</style>
